<template>
    <div class="pagebody">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item> <i class="el-icon-lx-cascades"></i> 包裹录单 </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="search-box">
                <el-form :inline="true">
                    <el-form-item label="包裹编号">
                        <el-input v-model="searchSet.code" prefix-icon="el-icon-search" clearable placeholder="请输入搜索信息"></el-input>
                    </el-form-item>
                    <el-form-item label="快递单号">
                        <el-input
                            v-model="searchSet.expressNumber"
                            prefix-icon="el-icon-search"
                            clearable
                            placeholder="请输入搜索信息"
                        ></el-input>
                    </el-form-item>
                    <el-form-item label="录单起止时间">
                        <el-date-picker
                            v-model="searchSet.startTime"
                            clearable
                            type="datetime"
                            placeholder="选择起始时间"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            align="right"
                            :picker-options="pickerTimeOptions"
                        >
                        </el-date-picker>
                        &nbsp; <label>~</label> &nbsp;
                        <el-date-picker
                            v-model="searchSet.endTime"
                            clearable
                            type="datetime"
                            placeholder="选择终止时间"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            align="right"
                            :picker-options="pickerTimeOptions"
                        ></el-date-picker>
                    </el-form-item>
                    <!-- <el-form-item label="客户手机号">
                        <el-input
                            v-model="searchSet.userMobile"
                            prefix-icon="el-icon-search"
                            clearable
                            placeholder="请输入搜索信息"
                        ></el-input>
                    </el-form-item> -->

                    <el-form-item label="客户代码">
                        <el-input
                            v-model="searchSet.userCode"
                            prefix-icon="el-icon-search"
                            clearable
                            placeholder="请输入搜索信息"
                        ></el-input>
                    </el-form-item>
                    <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
                    <el-button type="primary" icon="el-icon-plus" @click="handleAddNew">包裹入库</el-button>
                    <el-button type="primary" icon="el-icon-download" @click="handleExport">导出</el-button>
                </el-form>
            </div>
            <el-table :data="tableData" v-loading="tableLoading" border class="table" ref="mainTable" :row-class-name="tableRowClassName">
                <el-table-column prop="expressnumber" label="快递单号" min-width="100" align="center"></el-table-column>

                <el-table-column prop="code" label="包裹编号" min-width="100" align="center"></el-table-column>

                <el-table-column prop="couriername" label="快递公司" width="80" align="center"></el-table-column>
                <el-table-column prop="name" label="品名" align="center"></el-table-column>
                <el-table-column prop="weight" label="重量(KG)" width="80" align="center"></el-table-column>
                <el-table-column prop="count" label="数量" width="50" align="center"></el-table-column>

                <el-table-column prop="usercode" label="用户代码" min-width="80" :formatter="formatCode" align="center"></el-table-column>
                <el-table-column prop="claimtime" label="预报时间" align="center"></el-table-column>
                <el-table-column label="是否带电" width="100" align="center">
                    <template slot-scope="scope">
                        <div v-if="scope.row.hasbattery == 1" class="color-red">是</div>
                        <div v-else>否</div>
                    </template>
                </el-table-column>
                <el-table-column label="是否立即转运" width="100" align="center">
                    <template slot-scope="scope">
                        <div v-if="scope.row.cansendasap == 1" class="color-red">是</div>
                        <div v-else>否</div>
                    </template>
                </el-table-column>
                <el-table-column prop="addtime" label="录单时间" align="center"></el-table-column>
                <el-table-column prop="lastusername" label="经手人" align="center"></el-table-column>
                <el-table-column label="状态" align="center">
                    <template slot-scope="scope">
                        <div
                            class="CustomTag"
                            :style="{
                                'background-color': orderStatusOption[scope.row.status]
                                    ? orderStatusOption[scope.row.status].color
                                    : '#909399'
                            }"
                        >
                            {{ orderStatusOption[scope.row.status] ? orderStatusOption[scope.row.status].label : '无效' }}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="140" align="center">
                    <template slot-scope="scope">
                        <el-button type="text" icon="el-icon-s-order" @click="handleDetail(scope.$index, scope.row)">详情</el-button>
                        <el-button type="text" icon="el-icon-edit" @click="handleRepositoryIn(scope.$index, scope.row)">上架</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination
                    background
                    layout="sizes, total, prev, pager, next"
                    :current-page="query.index"
                    :page-sizes="[10, 20, 30, 40, 50, 100]"
                    :page-size="query.pageSize"
                    :total="itemTotal"
                    @current-change="handlePageChange"
                    @size-change="handlePageSizeChange"
                ></el-pagination>
            </div>
        </div>

        <el-dialog title="入库操作" v-dialogDrag center :visible.sync="editVisible" width="60%">
            <el-form ref="form" size="mini" :model="form" :rules="formRules" label-width="120px">
                <el-form-item label="存储仓库" prop="repositoryid">
                    <el-select v-model="form.repositoryid" class="formInput" @change="RepositoryChange" placeholder="请选择存储仓库">
                        <el-option v-for="item in repositoryDict" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="快递单号" prop="expressnumber">
                    <el-input
                        v-model="form.expressnumber"
                        ref="ExpressNumber"
                        @keyup.enter.native="ExpressNumberKeyEnter"
                        maxlength="30"
                        show-word-limit
                        placeholder="请填写快递单号"
                        clearable
                        class="formInput"
                    ></el-input>
                </el-form-item>
                <el-form-item label="快递公司" prop="courierId">
                    <el-select v-model="form.courierId" class="formInput" placeholder="请选择快递公司">
                        <el-option v-for="item in courierDict" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="商品类型" prop="cascaderGoodType">
                    <el-cascader
                        ref="cascader"
                        :props="goodTypes"
                        placeholder="请选择商品类型"
                        clearable
                        style="width: 100%"
                        v-model="form.cascaderGoodType"
                    ></el-cascader>
                </el-form-item>
                <el-form-item label="重量(KG)" prop="weight">
                    <el-input
                        v-model="form.weight"
                        placeholder="请填写重量(KG)"
                        maxlength="10"
                        show-word-limit
                        clearable
                        class="formInput"
                    ></el-input>
                </el-form-item>
                <el-form-item label="数量" prop="count">
                    <el-input-number class="formInput" placeholder="请填写数量" v-model="form.count" :min="1" :max="10"></el-input-number>
                </el-form-item>
                <el-form-item label="到付金额$" prop="freightprice">
                    <el-input
                        v-model="form.freightprice"
                        placeholder="请填写到付金额"
                        maxlength="10"
                        show-word-limit
                        clearable
                        class="formInput"
                        @input="calRmbfreightprice"
                    ></el-input>
                </el-form-item>
                <el-form-item label="汇率" prop="currencychangerate">
                    <el-input v-model="form.currencychangerate" maxlength="10" show-word-limit disabled class="formInput"></el-input>
                </el-form-item>
                <el-form-item label="到付金额￥" prop="localfreightprice">
                    <el-input
                        v-model="form.localfreightprice"
                        placeholder="请填写到付金额"
                        maxlength="10"
                        show-word-limit
                        clearable
                        class="formInput"
                        @input="calDollarfreightprice"
                    ></el-input>
                </el-form-item>

                <el-form-item label="图片">
                    <customUpload
                        accept="image/*"
                        ref="UploadImage"
                        :limit="3"
                        listType="picture-card"
                        tip="只能上传jpg/png文件"
                        v-on:update:idlist="UpdateImageList"
                    >
                    </customUpload>
                </el-form-item>
                <el-form-item label="视频">
                    <customUpload accept="video/*" ref="UploadVideo" :limit="3" tip="只能上传视频文件" v-on:update:idlist="UpdateVideoList">
                    </customUpload>
                </el-form-item>
            </el-form>

            <span slot="footer" class="dialog-footer">
                <el-button @click="cancelAdd">取 消</el-button>
                <el-button type="primary" @click="saveEdit">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="上架操作" v-dialogDrag center :visible.sync="repositoryInVisible" width="60%">
            <el-form ref="form" :model="formRepositoryIn" label-width="200px">
                <el-descriptions :column="1" style="margin-bottom: 20px" border>
                    <el-descriptions-item label="ID">
                        {{ formRepositoryIn.id }}
                    </el-descriptions-item>
                    <el-descriptions-item label="快递名称">
                        {{ formRepositoryIn.courierName }}
                    </el-descriptions-item>
                    <el-descriptions-item label="快递单号">
                        {{ formRepositoryIn.expressnumber }}
                    </el-descriptions-item>
                </el-descriptions>
                <el-form-item label="存放位置">
                    <el-select v-model="formRepositoryIn.repositoryregionid" style="width: 20%" placeholder="区域" @change="regionChange">
                        <el-option v-for="item in RegionList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                    <span style="margin: 0 10px">区域</span>
                    <el-select v-model="formRepositoryIn.repositoryshelfid" style="width: 20%" placeholder="货架" @change="shelfChange">
                        <el-option v-for="item in ShelfList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                    </el-select>
                    <span style="margin: 0 10px">货架</span>
                    <el-select v-model="formRepositoryIn.repositorylayerid" style="width: 20%" placeholder="货架">
                        <el-option v-for="item in LayerList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                    </el-select>
                    <span style="margin: 0 10px">层</span>
                    <el-input
                        v-model="formRepositoryIn.repositorynumber"
                        style="width: 30%"
                        placeholder="编号"
                        autofocus
                        maxlength="10"
                        clearable
                    >
                    </el-input>
                    <span style="margin: 0 10px">号</span>
                </el-form-item>
            </el-form>

            <span slot="footer" class="dialog-footer">
                <el-button @click="repositoryInVisible = false">取 消</el-button>
                <el-button type="primary" @click="saveRepositoryIn">确 定</el-button>
                <el-button type="primary" @click="printTag">打 印</el-button>
            </span>
        </el-dialog>
        <detailDialog :visible.sync="detailVisible" :data="detailInfo" :dataType="detailType"></detailDialog>
    </div>
</template>

<script>
import API from '../../../api/index'; //读入restfulAPI
import StringTool from '../../../utils/StringTool';
import JSTool from '../../../utils/JSTool';
import dataTable from './dataTable';
import moment from 'moment';
import MainTool from '../../../utils/MainTool';
import detailDialog from '../../common/dialog/detailDialog.vue';
import customUpload from '../../common/upload/customUpload.vue';
import axios from 'axios';

export default {
    name: 'packageInTable',
    mixins: [dataTable],
    components: {
        detailDialog,
        customUpload
    },
    data() {
        let CheckDigit = (rule, value, callback) => {
            if (!StringTool.DigitNumber(String(value))) {
                return callback(new Error('只能为整数和保留两位小数'));
            }
            if (Number(value) < 0) {
                return callback(new Error('只能为正数'));
            }
            callback();
        };
        return {
            searchSet: {
                expressNumber: '',
                startTime: '',
                endTime: '',
                code: '',
                userCode: '',
                userMobile: ''
            },
            formRepositoryIn: {
                repositoryregionid: '',
                repositoryshelfid: '',
                repositorylayerid: '',
                repositorynumber: '',
                id: ''
            },
            repositoryInVisible: false,
            RepositoryList: [],
            RegionList: [],
            ShelfList: [],
            LayerList: [],
            editVisible: false,
            form: {
                repositoryid: null,
                expressnumber: '',
                courierId: null,
                weight: '',
                count: 0,
                freightprice: 0,
                currencychangerateid: '',
                currencychangerate: 0,
                localfreightprice: 0
            },
            formRules: {
                repositoryid: [
                    { required: true, message: '参数不能为空', trigger: 'change' }
                    // { type: "number", message: '不合法的选择', trigger: 'blur' }
                ],
                courierId: [
                    { required: true, message: '参数不能为空', trigger: 'change' }
                    // { type: "number", message: '不合法的选择', trigger: 'blur' }
                ],
                expressnumber: [
                    { required: true, message: '参数不能为空', trigger: 'change' },
                    { min: 5, max: 30, message: '长度在 5 到 30 个字符', trigger: 'change' }
                ],
                name: [
                    { required: true, message: '参数不能为空', trigger: 'change' },
                    { min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'change' }
                ],
                weight: [{ validator: CheckDigit, required: true, trigger: 'change' }],
                count: [
                    { required: true, message: '参数不能为空', trigger: 'change' },
                    { type: 'number', message: '只能为数字', trigger: 'change' }
                ]
            },
            repositoryDict: [],
            courierDict: [],
            detailVisible: false,
            detailInfo: {},
            detailType: [
                {
                    attrs: { column: 2 },
                    list: [
                        { label: '包裹编号', key: 'code' },
                        { label: '录单时间', key: 'addtime' },
                        { label: '快递公司', key: 'couriername' },
                        { label: '快递单号', key: 'expressnumber' },
                        { label: '品名', key: 'name' },
                        { label: '到付金额$', key: 'freightprice' },
                        { label: '重量', key: 'weight' },
                        { label: '数量', key: 'count' },
                        {
                            label: '预报用户代码',
                            key: 'usercode',
                            span: 2,
                            format: (row, value) => {
                                if (row.userid == 0) return '————';
                                return value;
                            }
                        },
                        // {
                        //   label: "预报用户名称", key: "username", format: (row, value) => {
                        //     if (row.userid == 0) return "无绑定用户"
                        //     return StringTool.Empty(value) ? '无名称' : value
                        //   }
                        // },
                        { label: '图片列表', key: 'images', span: 2, type: 'imageList' },
                        { label: '视频列表', key: 'videos', span: 2, type: 'videoList' }
                    ]
                }
            ],

            orderStatusOption: {
                0: { label: '无效', value: '0', color: '#909399' },
                1: { label: '已入库', value: '1', color: '#409EFF' },
                2: { label: '已入柜', value: '2', color: '#0098d9' },
                3: { label: '待验货', value: '3', color: '#e6b600' },
                4: { label: '待退货', value: '4', color: '#e6b600' },
                5: { label: '待换货', value: '5', color: '#e6b600' },
                6: { label: '已出库', value: '6', color: '#67C23A' },
                7: { label: '已验货', value: '7', color: '#cda819' },
                8: { label: '已退货', value: '8', color: '#cda819' },
                9: { label: '已换货', value: '9', color: '#cda819' }
            },
            types: [],
            goodTypes: {
                lazy: true,
                lazyLoad: (node, resolve) => {
                    const { level } = node;
                    if (level == 0) {
                        let typeAList = [];
                        this.types.map((it) => {
                            typeAList.push({ label: it.name, value: it.id });
                        });
                        return resolve(typeAList);
                    } else {
                        let typeBList = [];
                        for (let typeA of this.types) {
                            if (typeA.id == node.data.value) {
                                typeA.list.map((item) => {
                                    typeBList.push({ label: item.name, value: item.id });
                                });
                            }
                        }
                        return resolve(typeBList);
                    }
                }
            }
        };
    },
    created() {
        this.init();
    },
    watch: {
        editVisible: function (val) {}
    },
    methods: {
        ExpressNumberKeyEnter() {
            this.$refs.form.validateField('expressnumber', (errMsg) => {
                if (!errMsg) {
                    const loading = this.$loading({
                        lock: true,
                        text: '获取快递信息中',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    API.StandardDoWith(API.PackageInPre.Get({ expressnumber: this.form.expressnumber }), this, {
                        success: (detail) => {
                            if (detail.courierId && Number(detail.courierId) != 0) {
                                this.form.courierId = detail.courierId;
                            }
                        },
                        complete: () => {
                            loading.close();
                        }
                    });
                } else {
                    this.$message.error(`快递单号验证失败，无法获取`);
                    return false;
                }
            });
        },
        //页面初始化
        init() {
            this.getData();

            API.StandardDoWith(API.Repository.Get({ pageSize: 20, status: 1 }), this, {
                success: (detail) => {
                    let dict = {};
                    detail.list.map((it) => {
                        dict[it.id] = it;
                    });
                    this.repositoryDict = dict;
                    this.RepositoryList = detail.list;
                }
            });
            API.StandardDoWith(API.Courier.Get({ pageSize: 1000, status: 1, type: 2 }), this, {
                success: (detail) => {
                    let dict = {};
                    detail.list.map((it) => {
                        dict[it.id] = it;
                    });
                    this.courierDict = dict;
                }
            });
            API.StandardDoWith(API.Goodtypel.Get({ pageSize: 99, status: 1 }), this, {
                success: (detail) => {
                    this.types = detail.list;
                }
            });
            // API.StandardDoWith(API.Repository.Get({ pageSize: 99, status: 1 }), this, {
            //     success: (detail) => {
            //         this.RepositoryList = detail.list;
            //     }
            // });
        },
        UpdateImageList(idlist) {
            this.form.images = idlist;
        },
        UpdateVideoList(idlist) {
            this.form.videos = idlist;
        },

        calRmbfreightprice() {
            this.form.localfreightprice = (parseFloat(this.form.freightprice) * parseFloat(this.form.currencychangerate)).toFixed(2);
        },
        calDollarfreightprice() {
            this.form.freightprice = (parseFloat(this.form.localfreightprice) / parseFloat(this.form.currencychangerate)).toFixed(2);
        },

        handleRepositoryIn(index, row) {
            //仅单层拷贝
            this.formRepositoryIn = {
                repositoryregionid: '',
                repositoryshelfid: '',
                repositorylayerid: '',
                repositorynumber: '',
                id: row.packageid
            };

            for (let rep of this.RepositoryList) {
                if (rep.id == row.repositoryid) {
                    this.RegionList = rep.regions;
                }
            }
            // for (let region of this.RegionList) {
            //     if (region.id == row.repositoryregionid) {
            //         this.ShelfList = region.shelfs;
            //     }
            // }
            // for (let shelf of this.ShelfList) {
            //     if (shelf.id == row.repositoryshelfid) {
            //         this.LayerList = shelf.layers;
            //     }
            // }
            this.repositoryInVisible = true;
        },
        getData() {
            this.tableLoading = true;
            API.StandardDoWith(API.PackageIn.Get(this.getQuery()), this, {
                success: (detail) => {
                    this.itemTotal = detail.count;
                    detail.list.map((it) => {
                        it.addtime = moment(it.addtime).format('YYYY-MM-DD HH:mm');
                    });
                    this.tableData = detail.list;

                    this.form.currencychangerateid = detail.currencychangerateid;
                    this.form.currencychangerate = detail.currencychangerate;
                },
                complete: () => {
                    this.tableLoading = false;
                }
            });
        },
        handleAddNew() {
            this.editVisible = true;
            let currencychangerateid = this.form.currencychangerateid;
            let currencychangerate = this.form.currencychangerate;
            let repositoryid = localStorage.getItem('RepositoryId');
            if (repositoryid && !this.repositoryDict[repositoryid]) {
                repositoryid = null;
                localStorage.removeItem('RepositoryId');
            }
            this.form = {
                repositoryid,
                expressnumber: '',
                courierId: null,
                weight: '',
                count: '',
                freightprice: 0,
                currencychangerateid: currencychangerateid,
                currencychangerate: currencychangerate,
                localfreightprice: 0,
                images: [],
                videos: [],
                cascaderGoodType: []
            };
            this.$nextTick(() => {
                this.$refs.ExpressNumber.focus();
            });
        },
        RepositoryChange(val) {
            localStorage.setItem('RepositoryId', val);
        },
        requestAddNew(data) {
            API.StandardDoWith(API.PackageIn.Post(data), this, {
                loading: '包裹录单处理中',
                success: (detail) => {
                    this.editVisible = false;
                    this.$message.success(`包裹录单成功`);
                    this.$refs.UploadImage.Clear();
                    this.$refs.UploadVideo.Clear();
                    this.getData();
                }
            });
        },

        // 保存编辑
        saveEdit() {
            this.$refs.form.validate((valid) => {
                if (valid) {
                    let form = Object.assign({}, this.form);
                    form.count = Number(form.count);
                    form.weight = Number(form.weight);
                    form.payedprice = Number(form.payedprice);
                    form.freightprice = Number(form.freightprice);
                    form.localfreightprice = Number(form.localfreightprice);
                    form.goodtypel1id = form.cascaderGoodType[0];
                    form.goodtypel2id = form.cascaderGoodType[1];
                    console.log(form);

                    this.requestAddNew(form);
                } else {
                    this.$message.error(`表单验证失败，无法提交`);
                    return false;
                }
            });
        },
        cancelAdd() {
            this.$refs.UploadImage.Clear();
            this.$refs.UploadVideo.Clear();
            this.editVisible = false;
        },
        formatCode(row, column, cellValue, index) {
            if (row.userid == 0) return '无预报用户';
            return cellValue;
        },
        formatName(row, column, cellValue, index) {
            if (row.userid == 0) return '无预报用户';
            return StringTool.Empty(cellValue) ? '无名称' : cellValue;
        },

        handleDetail(index, row) {
            this.detailVisible = true;
            let obj = Object.assign({}, row);
            obj.images = MainTool.FileIdToUrl(obj.images);
            obj.videos = MainTool.FileIdToUrl(obj.videos);
            this.detailInfo = obj;
        },
        tableRowClassName({ row, rowIndex }) {
            if (row.userid != 0) {
                return 'success-row';
            }
            return 'warning-row';
        },
        handleExport() {
            this.$confirm('是否导出Excel数据?', '提示')
                .then(() => {
                    API.StandardDownFile(API.PackageInExport(), '包裹录单数据.xlsx');
                })
                .catch((err) => {});
        },
        regionChange(val) {
            this.ShelfList = [];
            this.LayerList = [];
            this.formRepositoryIn.repositoryshelfid = '';
            this.formRepositoryIn.repositorylayerid = '';
            for (let region of this.RegionList) {
                if (region.id == val) {
                    this.ShelfList = region.shelfs;
                }
            }
        },
        shelfChange(val) {
            this.LayerList = [];
            this.formRepositoryIn.repositorylayerid = '';
            for (let shelf of this.ShelfList) {
                if (shelf.id == val) {
                    this.LayerList = shelf.layers;
                }
            }
        },
        printTag() {
            let { repositoryregionid, repositoryshelfid, repositorylayerid, repositorynumber, code } = this.formRepositoryIn;
            if (!repositoryregionid || StringTool.Empty(repositoryregionid.trim())) {
                this.$message.error(`请填写货架位置`);
                return false;
            }
            if (!repositoryshelfid || StringTool.Empty(repositoryshelfid.trim())) {
                this.$message.error(`请填写货架位置`);
                return false;
            }
            if (!repositorylayerid || StringTool.Empty(repositorylayerid.trim())) {
                this.$message.error(`请填写货架位置`);
                return false;
            }

            if (!repositorynumber || StringTool.Empty(repositorynumber.trim())) {
                this.$message.error(`请填写货架位置`);
                return false;
            }
            let repositoryregionname = '';
            let repositoryshelfname = '';
            let repositorylayername = '';
            for (let region of this.RegionList) {
                if (region.id == repositoryregionid) {
                    repositoryregionname = region.name;
                    break;
                }
            }
            for (let shelf of this.ShelfList) {
                if (shelf.id == repositoryshelfid) {
                    repositoryshelfname = shelf.name;
                    break;
                }
            }
            for (let layer of this.LayerList) {
                if (layer.id == repositorylayerid) {
                    repositorylayername = layer.name;
                    break;
                }
            }
            console.log(repositoryregionname, repositoryshelfname, repositorylayername, repositorynumber, code);
            let printUrl =
                'http://localhost:9027/api/print?l=' +
                repositoryregionname +
                repositoryshelfname +
                repositorylayername +
                repositorynumber +
                '&b=' +
                code;

            axios.get(printUrl);
        },
        saveRepositoryIn() {
            let { id, repositoryregionid, repositoryshelfid, repositorylayerid, repositorynumber } = this.formRepositoryIn;
            if (!repositoryregionid || StringTool.Empty(repositoryregionid.trim())) {
                this.$message.error(`请填写货架位置`);
                return false;
            }
            if (!repositoryshelfid || StringTool.Empty(repositoryshelfid.trim())) {
                this.$message.error(`请填写货架位置`);
                return false;
            }
            if (!repositorylayerid || StringTool.Empty(repositorylayerid.trim())) {
                this.$message.error(`请填写货架位置`);
                return false;
            }

            if (!repositorynumber || StringTool.Empty(repositorynumber.trim())) {
                this.$message.error(`请填写货架位置`);
                return false;
            }
            // let location = locatCode;
            // if (locatB) location = locatB + '架' + location;
            // if (locatA) location = locatA + '区' + location;
            this.requestRepositoryIn(id, repositoryregionid, repositoryshelfid, repositorylayerid, repositorynumber);
        },
        requestRepositoryIn(id, repositoryregionid, repositoryshelfid, repositorylayerid, repositorynumber) {
            API.StandardDoWith(
                API.RepositoryIn.Post({ id, repositoryregionid, repositoryshelfid, repositorylayerid, repositorynumber }),
                this,
                {
                    success: (detail) => {
                        this.repositoryInVisible = false;
                        this.$message.success(`入柜操作成功`);
                        this.getData();
                    }
                }
            );
        }
    }
};
</script>

<style scoped>
@import '../../../assets/css/dataTable.css';
</style>
